package client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
/**
 * Public class. Establishes connection and I/O strems.
 * @author agurgul
 *
 */
public class ClientThread implements Runnable{
	private Socket clientSocket;
	private int port;
	private final PrintWriter output;
	private final BufferedReader input;

	public PrintWriter getOutput() {
		return output;
	}

	public BufferedReader getInput() {
		return input;
	}
	
	public ClientThread(String adress, String portS) throws Exception{
		try{
			this.port = Integer.parseInt(portS);
		}catch(NumberFormatException e){
			throw new Exception("Nieprawidlowy port!");
		}
		System.out.println(adress + ":"+port);
		clientSocket = new Socket(adress, this.port);
		output = new PrintWriter(clientSocket.getOutputStream(), true);
		input = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
	}
	public void run(){};
}
